﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SmartSpace.UI.Silverlight.Dynamic.DynamicRef;
using SmartSpace.UI.Silverlight.Dynamic.Windows;

namespace SmartSpace.UI.Silverlight.Dynamic.Commands
{
    public class WfHistoryCommand : ICommand
    {
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            HyperlinkButton button = parameter as HyperlinkButton;
            if (button == null)
            {
                return;
            }

            DataInstance data = button.DataContext as DataInstance;
            if (data == null)
            {
                return;
            }
            
            ListTemplateView slView = button.Tag as ListTemplateView;
            WfHistoryWindow window = new WfHistoryWindow(slView.WorkflowId, data.Id);
            window.Show();
        }
    }
}
